#include <iostream>
#include <string>
#include <vector>
#include <list>

using namespace std;

typedef struct book
{
    string name;
    int id;
} book;

ostream &operator<<(ostream &os, book &my)
{
    os << "书名:" << my.name << "编号:" << my.id;
    return os;
}

book book_data[10] = {
    {.name = "《母猪产后护理》", .id = 1},
    {.name = "《关于找对象的101种技巧》", .id = 2},
    {.name = "《富婆通讯录》", .id = 3},
    {.name = "《霸道总裁爱上我》", .id = 4},
    {.name = "《如何一夜暴富》", .id = 5},
    {.name = "《郑迎佳自传》", .id = 6},
    {.name = "《葵花宝典&辟邪剑谱修炼心得》", .id = 7}};

int main(int argc, char const *argv[])
{
    // 删  改

    vector<book> book_list;

    for (size_t i = 0; i < 7; i++)
    {
        book_list.push_back(book_data[i]);
    }
    int id;

    cout << "请输入你需要查找的 id" << endl;
    cin >> id;

    // 查找的方法 1
    for (auto it = book_list.cbegin(); it != book_list.end(); it++)
    {
        book book_temp = *it;
        if (id == book_temp.id)
        {
            cout << "书名:" << book_temp.name << endl;
            cout << "编号:" << book_temp.id << endl;
        }
    }

    //
    for (size_t i = 0; i < book_list.size(); i++)
    {
        book book_temp = book_list[i];
    }

    return 0;
}